
function initPmtk3Octave()
more off
%% Initialize PMTK3 for Octave
w = which(mfilename());
if w(1) == '.' % for octave compatability
    w = fullfile(pwd, w(3:end));
end
thisDir = fileparts(w);
cd(thisDir);
restoredefaultpath();
addpath(genpath(pwd));
% if ~exist('matlabToolsRoot', 'file')
%     url = 'http://matlabtools.googlecode.com/svn/trunk/matlabTools.zip';
%     fprintf('downloading matlabTools.............');
%     dest = fullfile(thisDir, 'matlabTools', 'matlabTools.zip');
%     downloadFile(url, dest);       % more reliable than unzip(url, ...
%     unzip(dest, fileparts(dest)); 
%     addpath(genpath(fullfile(thisDir, 'matlabTools')));
%     fprintf('done\n');
% end
%%
pmtkInfoDir = fullfile(thisDir, 'pmtkTools', 'systemInfo');
%% write isOctave function
text = { 'function answer = isOctave()'
    '%autogenerated by initPmtk3()'
    sprintf('answer = 1;');
    'end'
    };
writeText(text, fullfile(pmtkInfoDir, 'isOctave.m'));
%% write is*ToolboxInstalled functions
toolbox = {'stats', 'bioinfo', 'optim', 'signal', 'images', 'symbolic',...
    'nnet', 'splines'};
for t=1:numel(toolbox)
    fname =   sprintf('%sToolboxInstalled', toolbox{t});
    text  = { sprintf('function answer = %s()', fname)
              '% autogenerated by initPmtk3()'
               sprintf('answer = 0;')
              'end'
            };
    writeText(text, fullfile(pmtkInfoDir, [fname, '.m']));
end
%% include PMTK support
if ~(exist('pmtkSupportRoot', 'file') == 2)
    downloadAllSupport();
end
restoredefaultpath();
addpath(genpath(pwd));  % octave path management can be buggy - make sure
disp('welcome to pmtk3');
end
